//
//  FirstMusicCollectionViewCell.m
//  OurRelaxDemo
//
//  Created by 王雅蓉 on 15/6/23.
//  Copyright (c) 2015年 于宾尧. All rights reserved.
//

#define ScreenHeight [UIScreen mainScreen].bounds.size.height
#define ScreenWidth [UIScreen mainScreen].bounds.size.width
#define GapOfImage 10.0

#import "FirstMusicCollectionViewCell.h"
#import <UIImageView+WebCache.h>

@interface FirstMusicCollectionViewCell ()

@end

@implementation FirstMusicCollectionViewCell

-(void)dealloc
{
    [_firstL release];
    [_firstMusic release];
    
    [super dealloc];
}

-(instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        
        [self createSubviews];
        _firstMusic = [[MusicModel alloc]init];
        
    }
    
    return self;
}

-(void)createSubviews
{
    //self.backgroundColor = [UIColor yellowColor];
    imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height - 30)];
    imageView.backgroundColor = [UIColor cyanColor];
    imageView.layer.masksToBounds = YES;
    imageView.layer.cornerRadius = 20;
    imageView.userInteractionEnabled = YES;
    [self.contentView addSubview:imageView];
    [imageView release];
    
    _firstL = [[UILabel alloc] initWithFrame:CGRectMake(10, imageView.frame.size.height, self.frame.size.width, 30)];
    _firstL.font = [UIFont systemFontOfSize:15.0];
    _firstL.textColor = [UIColor grayColor];
    [self.contentView addSubview:_firstL];
    [_firstL release];
}

-(void)setFirstMusic:(MusicModel *)firstMusic
{
    if (_firstMusic != firstMusic) {
        
        [_firstMusic release];
        _firstMusic = [firstMusic retain];
        
    }
    
    NSString *urlStr = [firstMusic.pic stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    NSURL *url = [NSURL URLWithString:urlStr];
    [imageView sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"musicWebCache.jpeg"]];
    
    _firstL.text = firstMusic.title;
    
}

@end
